package com.product.android.commonInterface.allCommonInterfaceImpl;

import com.product.android.business.ApplicationVariable;
import com.product.android.business.bean.UserInfo;
import com.product.android.business.login.BindUser;
import com.product.android.commonInterface.BaseCommonStruct;
import com.product.android.commonInterface.CIConst;
import com.product.android.commonInterface.CommonInterfaceManager;
import com.product.android.commonInterface.contact.OapGroup;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

/**
 * allCommon调用其他模块接口 ClassName:AllCommonCallOtherModel Function: TODO ADD
 * FUNCTION Reason: TODO ADD REASON
 * 
 * @author 黄永鑫
 * @version
 * @since Ver 1.1
 * @Date 2014 2014-2-26 下午3:22:04
 * 
 * @see
 */
public class AllCommonCallOtherModel {
	public static final String AllCOMMON_CALL_TAG = "AllCommonCallOtherModel";
	
	public static class NdCommonModel {

		/**
		 * 保存用户信息
		 * 
		 * @n<b>函数名称</b> :saveUserInfo
		 * @brief
		 * @see
		 * @since Ver 1.1
		 * @param @param userInfo
		 * @return void
		 * @<b>作者</b> : 黄永鑫
		 * @<b>创建时间</b> : 2014-2-26下午3:24:55
		 */
		public static void saveUserInfo(UserInfo userInfo) {
			BaseCommonStruct param = new BaseCommonStruct();
			param.obj1 = userInfo;
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.NDCOMMON_MODELID,
					CIConst.NDCOMMON_SAVE_USERINFO_40001, param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "saveUserInfo:" + ret);
			}
		}

		/**
		 * 获取最后一个登陆用户
		 * 
		 * @n<b>函数名称</b> :getLastUserInfo
		 * @brief
		 * @see
		 * @since Ver 1.1
		 * @param @param type NdLoginConst.LOGIN_TYPE_UAP = 0;
		 *        NdLoginConst.LOGIN_TYPE_OAP = 1; NdLoginConst.LOGIN_TYPE_ND =
		 *        2;
		 * @param @return
		 * @return UserInfo
		 * @<b>作者</b> : 黄永鑫
		 * @<b>创建时间</b> : 2014-2-26下午3:46:29
		 */
		public static UserInfo getLastUserInfo(int type) {
			BaseCommonStruct param = new BaseCommonStruct();
			param.iPara = type;
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.NDCOMMON_MODELID,
					CIConst.NDCOMMON_GET_LAST_LOGIN_USER_40002, param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "getLastUserInfo:" + ret);
			}
			if (param.obj2 instanceof UserInfo)
				return (UserInfo) param.obj2;
			return null;
		}
	}

	public static class MainModel {
		
	    /**
	     * 首次登录时获取用户信息
	     * 
	     * <br>Created 2014-10-23 下午9:05:02
	     * @param userInfo     登录返回的用户信息
	     * @return             BindUser
	     * @author       linsj
	     */
        public static BindUser getInitCurrentUser(UserInfo userInfo) {
            BaseCommonStruct param = new BaseCommonStruct();
            param.obj1 = userInfo;
            int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
                    CIConst.MAIN_MODELID, CIConst.MAIN_GET_CURRENT_INIT_USER_91005,
                    param);
            if (ret != CIConst.COM_RET_OK) {
                Log.e(AllCOMMON_CALL_TAG, "getCurrentUser:" + ret);
            }
            if (param.obj2 instanceof BindUser)
                return (BindUser) param.obj2;
            return null;
        }
		
		/**
		 * 
		 * @n<b>函数名称</b> :getCurrentUser
		 * @brief
		 * @see
		 * @since Ver 1.1
		 * @param @param userInfo
		 * @return void
		 * @<b>作者</b> : 黄永鑫
		 * @<b>创建时间</b> : 2014-2-26下午4:02:30
		 */
		public static BindUser getCurrentUser(UserInfo userInfo) {
			BaseCommonStruct param = new BaseCommonStruct();
			param.obj1 = userInfo;
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.MAIN_MODELID, CIConst.MAIN_GET_CURRENT_USER_91001,
					param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "getCurrentUser:" + ret);
			}
			if (param.obj2 instanceof BindUser)
				return (BindUser) param.obj2;
			return null;
		}

		/**
		 * 跳转到积分领取界面
		 * 
		 * @n<b>函数名称</b> :toReceivePoint
		 * @brief
		 * @see
		 * @since Ver 1.1
		 * @param @param activity
		 * @return void
		 * @<b>作者</b> : 黄永鑫
		 * @<b>创建时间</b> : 2014-2-26下午4:10:59
		 */
		public static void toReceivePoint(Context context) {
			BaseCommonStruct param = new BaseCommonStruct();
			param.obj1 = context;
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.MAIN_MODELID,
					CIConst.MAIN_ACTIVITY_TO_RECEIVEPOINT_92003, param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "toReceivePoint:" + ret);
			}
		}

		/**
		 * 跳转到登陆界面
		 * 
		 * @n<b>函数名称</b> :toLoginActivity
		 * @brief
		 * @see
		 * @since Ver 1.1
		 * @param @param cContext
		 * @return void
		 * @<b>作者</b> : 黄永鑫
		 * @<b>创建时间</b> : 2014-2-26下午4:14:34
		 */
		public static void toLoginActivity(Context context) {
			BaseCommonStruct param = new BaseCommonStruct();
			param.obj1 = context;
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.MAIN_MODELID, CIConst.MAIN_ACTIVITY_TO_LOGIN_92001,
					param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "toLoginActivity:" + ret);
			}
		}

		/**
		 * 重新登陆获取sid
		 * 
		 * @n<b>函数名称</b> :getRelginSid
		 * @brief
		 * @see
		 * @since Ver 1.1
		 * @param @return
		 * @return String
		 * @<b>作者</b> : 黄永鑫
		 * @<b>创建时间</b> : 2014-2-26下午4:23:01
		 */
		public static String getRelginSid() {
			BaseCommonStruct param = new BaseCommonStruct();
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.MAIN_MODELID, CIConst.MAIN_ON_GET_RELOGINSID_91002,
					param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "getRelginSid:" + ret);
			}
			if (param.obj2 instanceof String)
				return (String) param.obj2;
			return "";
		}
		
		/**
		 * @n<b>函数名称</b>     :loginAndGetSid
		 * @brief 登录并获取sid
		 * @version    Ver 1.0.0
		 * @param  @return
		 * @return String
		 * @<b>作者</b>          :  cb
		 * @<b>创建时间</b>      :  2014-4-15上午10:59:07      
		*/
		public static String loginAndGetSid() {
			BaseCommonStruct param = new BaseCommonStruct();
			param.obj1=ApplicationVariable.INSTANCE.getCurrentUserInfo();
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.MAIN_MODELID, CIConst.MAIN_IMS_NO_SID_LOGIN_91003,
					param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "loginAndGetSid:" + ret);
			}
			return param.sPara;
		}
	}

	public static class ContactModel {
		public static String getGroupName(OapGroup oapUser) {
			BaseCommonStruct param = new BaseCommonStruct();
			param.obj1 = oapUser;
			int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(
					CIConst.CONTACT_MODELID,
					CIConst.CONTACT_GET_OAP_GROUP_NAME_10317, param);
			if (ret != CIConst.COM_RET_OK) {
				Log.e(AllCOMMON_CALL_TAG, "ContactModel getGroupName:" + ret);
			}
			return param.sPara;
		}
		
	}
	
	public static class WeiboModel{
	    /**
	     * 跳转到话题微博页面
	     * 
	     * <br>Created 2014-8-21 下午1:53:23
	     * @param tagName 话题名
	     * @author       PanYun
	     */
        public static void gotoHashTagsListActivity(Activity activity,String tagName) {
            BaseCommonStruct param = new BaseCommonStruct();
            param.obj1 = activity;
            param.sPara = tagName;
            int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(CIConst.WEIBO_MODELID,
                    CIConst.WEIBO_ACTIVITY_TO_HASHTAGSLIST_32105, param);
            if(ret != CIConst.COM_RET_OK){
                Log.e(AllCOMMON_CALL_TAG, "gotoHashTagsListActivity:" + ret);
            }
        }
        
        
        /**
         * 跳转到个人主页
         * 
         * <br>Created 2014-8-21 下午1:56:12
         * @param uid 用户uid
         * @author       PanYun
         */
        public static void gotoTweetProfileActivity(Activity activity,long uid){
            BaseCommonStruct param = new BaseCommonStruct();
            param.lPara = uid;
            param.obj1 = activity;
            int ret = CommonInterfaceManager.INSTANCE.CommonInterfaceID(CIConst.WEIBO_MODELID,
                    CIConst.WEIBO_ACTIVITY_TO_PROFILE_32101, param);
            if(ret != CIConst.COM_RET_OK){
                Log.e(AllCOMMON_CALL_TAG, "gotoTweetProfileActivity:" + ret);
            }
        }
	}
}
